package com.tuling.designpattern.flyweight;

import java.util.HashMap;

/**
 * @author 林瑞涛
 * @desc 网站工厂类
 * @date 2021年07月31日 14:11
 */
public class WebSiteFactory {
    private HashMap<String, ConcreteWebSite> pool = new HashMap<>();

    //获取网站分类
    public WebSite getWebSiteCategory(String key){
        if(!pool.containsKey(key)){
            pool.put(key, new ConcreteWebSite(key));
        }
        return pool.get(key);
    }


    //获得网站分类总数
    public int getWebSiteCount(){
        return pool.size();
    }
}
